﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameSDK.Player;
using GuessNumberGame.Board;

namespace GuessNumberGame.Player
{
    public class HumanStrategy : GuessNumberStrategy
    {

        #region Constructor
        public HumanStrategy(GuessNumberPlayer player) : base(player)
        {
        }

        #endregion

        public override void DoMove()
        {
            //throw new NotImplementedException();
            int proposal;
            string UserEntry = "";
            bool IsOk = false;
            do
            {
                Console.WriteLine( this.Player + " : Please Write your Proposition (Number) :");
                UserEntry = Console.ReadLine();
                IsOk = int.TryParse(UserEntry, out proposal);
            } while (!IsOk);

            GuessNumberMove move = new GuessNumberMove(((GuessNumberBoard) Player.Board), proposal);

            if (move.EvaluateMove() > 0)
            {
                Console.WriteLine(Player.GamePlayerId + " : -");
                Player.Board.PlayerMoved(Player, move);                
            }
            else if (move.EvaluateMove() < 0)
            {
                Console.WriteLine(Player.GamePlayerId + " : +");
                Player.Board.PlayerMoved(Player, move);
            }
            else
            {
                Console.WriteLine(Player.GamePlayerId + " : win");
            }
        }


    }
}
